<%@page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@include file="/wx/page/session.jsp"%>
<c:set var="userId" value="${param.userId}" />
<c:set var="deptId" value="${param.deptId}" />
<c:set var="deptCode" value="${param.deptCode}" />
<c:set var="deptParentId" value="${param.deptParentId}" />
<c:set var="taskId" value="${param.taskId}" />
<c:set var="staffType" value="${param.staffType}" />
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no, width=device-width">
    <meta content="yes" name="apple-mobile-web-app-capable">
    <meta content="black" name="apple-mobile-web-app-status-bar-style">
    <title>任务详情</title>
    <link rel="stylesheet" href="${ctx}/wx/css/default.css"/>
    <script type="text/javascript" src="${ctx}/dwr/engine.js"></script>
    <script type="text/javascript" src="${ctx}/dwr/util.js"></script>
    <script type="text/javascript" src="${ctx}/dwr/interface/TaskService.js"></script>
    <script type="text/javascript" src="${ctx}/wx/js/alert.js"></script>
</head>
<body style="text-align: center;">
<form id="taskForm" name="taskForm" method="post">
    <fieldset class="contact-inner">
        <input type="hidden" id="deptId" name="deptId" value="${deptId}">
        <input type="hidden" id="userId" name="userId" value="${userId}">
        <input type="hidden" id="taskId" name="taskId" value="${taskId}">
        <input type="hidden" id="taskSenderUserId" name="taskSenderUserId">
        <p class="contact-submit">
            <input type="button" value="保存任务单状态" onclick="updateTaskState()">
        </p>
        <p class="contact-input" style="text-align: left">
            <input type="checkbox" id="taskPublishState" name="taskPublishState" style="width: 20px; height: 20px;">
            <label for="taskPublishState" style="width: 20px">发布到任务大厅</label>
        </p>
        <p class="contact-input" style="text-align: left">
            <label>完成状态：</label>
            <select id="taskState" name="taskState" style="width: 150px">
                <option value="0">未完成</option>
                <option value="1">已完成</option>
            </select>
        </p>
        <p class="contact-input" style="text-align: left">
            <label>任务类型：</label>
            <label id="taskType"></label>
        </p>
        <p class="contact-input" style="text-align: left">
            <label>货主姓名：</label>
            <label id="taskSenderUserName"></label>
        </p>
        <p class="contact-input" style="text-align: left">
            <label>货主电话：</label>
            <label id="taskSenderUserMobile"></label>
        </p>
        <p class="contact-input" style="text-align: left">
            <label>货物类型：</label>
            <label id="taskGoodsType"></label>
        </p>
        <p class="contact-input" style="text-align: left">
            <label>货物规格：</label>
            <label id="taskGoodsStandard"></label>
        </p>
        <p class="contact-input" style="text-align: left">
            <label>货物总数：</label>
            <label id="taskLoadSum"></label>
            <label>(吨)</label>
        </p>
        <p class="contact-input" style="text-align: left">
            <label>需要车辆：</label>
            <label id="taskTruckTotalNum"></label>
            <label>(辆)</label>
        </p>
        <p class="contact-input" style="text-align: left">
            <label>已有车辆：</label>
            <label id="taskTruckOccupyNum"></label>
            <label>(辆)</label>
        </p>
        <p class="contact-input" style="text-align: left">
            <label>信息费：</label>
            <label id="taskCostPrice"></label>
            <label>(元/辆)</label>
        </p>
        <p class="contact-input" style="text-align: left">
            <label>信息费总额：</label>
            <label id="taskCostPriceSum" style="color: red"></label>
            <label>(元)</label>
        </p>
        <p class="contact-input" style="text-align: left">
            <label>运费单价：</label>
            <label id="taskFreightPrice"></label>
            <label>(元/吨)</label>
        </p>
        <p class="contact-input" style="text-align: left">
            <label>运费总额：</label>
            <label id="taskFreightSum"></label>
            <label>(元)</label>
        </p>
        <p class="contact-input" style="text-align: left">
            <label>运费支付方式：</label>
            <label id="taskPayWay"></label>
        </p>
        <c:if test="${staffType == 1}">
            <p class="contact-input" style="text-align: left">
                <label>采购单价：</label>
                <label id="taskPurchasePrice"></label>
                <label>(元/吨)</label>
            </p>
            <p class="contact-input" style="text-align: left">
                <label>采购总额：</label>
                <label id="taskPurchaseSum"></label>
                <label>(元)</label>
            </p>
            <p class="contact-input" style="text-align: left">
                <label>销售单价：</label>
                <label id="taskSalePrice"></label>
                <label>(元/吨)</label>
            </p>
            <p class="contact-input" style="text-align: left">
                <label>销售总额：</label>
                <label id="taskSaleSum"></label>
                <label>(元)</label>
            </p>
        </c:if>
        <!--p class="contact-input" style="text-align: left">
            <label>购买货运保险：</label>
            <label id="taskInsurance"></label>
        </p>
        <p class="contact-input" style="text-align: left">
            <label>保额：</label>
            <label id="taskPremium"></label>
            <label>(万元)</label>
        </p-->
        <p class="contact-input" style="text-align: left">
            <label>装货地点：</label>
            <label id="taskLoadingArea"></label><br>
            <label id="taskLoadingAddress"></label>
        </p>
        <p class="contact-input" style="text-align: left">
            <label>卸货地点：</label>
            <label id="taskUnloadingArea"></label><br>
            <label id="taskUnloadingAddress"></label>
        </p>
        <p class="contact-input" style="text-align: left">
            <label>备注：</label>
            <label id="taskRemark"></label>
        </p>
    </fieldset>
</form>
</body>
</html>
<script type="text/javascript">
    parent.document.title = "任务详情";
    if("${taskId}".length > 0) {
        var task = new Task();
        task.deptId = "${deptId}";
        task.taskId = "${taskId}";
        TaskService.selectTaskList(task, callbackSelectTaskList);
    }
    function callbackSelectTaskList(list) {
        var task = list[0];
        dwr.util.setValues(task);
        dwr.util.setValue("taskType", task.taskType == 1 ? "煤贸" : task.taskType == 2 ? "运输" : "");
        dwr.util.setValue("taskPublishState", task.taskPublishState);
        var bill = new Bill();
        bill.taskId = "${taskId}";
        TaskService.selectBillTruckSum(bill, callbackSelectBillTruckSum);
    }
    function callbackSelectBillTruckSum(list) {
        var array = list[0];
        dwr.util.setValue("taskLoadSum", array[0]);
        <c:if test="${staffType == 1}">
        dwr.util.setValue("taskPurchaseSum", array[1]);
        dwr.util.setValue("taskSaleSum", array[2]);
        </c:if>
        dwr.util.setValue("taskFreightSum", array[3]);
        dwr.util.setValue("taskCostPriceSum", array[4]);
    }
    function updateTaskState() {
        var task = new Task();
        task.taskId = "${taskId}";
        task.taskPublishState = dwr.util.getValue("taskPublishState");
        task.taskState = dwr.util.getValue("taskState");
        TaskService.updateTask(task, callback);
    }
    function callback() {
        location = "${ctx}/wx/page/task_list.jsp?userId=${userId}&deptId=${deptId}&deptCode=${deptCode}&deptParentId=${deptParentId}";
    }
</script>